#!/bin/bash
if docker ps >/dev/null 2>&1; then
    :
else
    echo "未安装docker" >&2
    return -1
fi

echo "创建数据挂载目录..."
mkdir /zjx_class
mkdir /zjx_class/minioData
mkdir /zjx_class/mysqlData
echo "创建数据挂载目录完毕"

var=$(docker network list)
if [[ $var =~ "zjx_class" ]];then
    echo "已初始化网络"
else
    docker network create -d bridge zjx_class
    echo "创建私有网络"
fi
echo "开始拉取镜像"

docker pull 2359971480/zjx_backend:latest_alpine
docker pull 2359971480/zjx_static:alpine_latest
docker pull 2359971480/zjx_preview_file:latest_alpine
docker pull 2359971480/zjx_front:latest_alpine
docker pull 2359971480/zjx_backend_front:latest_alpine
docker pull 2359971480/zjx_gateway:alpine_lastest
docker pull mysql:8.0.28
docker pull minio/minio:RELEASE.2022-02-07T08-17-33Z
docker pull redis:7.0-rc1-alpine3.15

docker run --name zjx_redis --net zjx_class -d  redis:7.0-rc1-alpine3.15 --requirepass "990812"
docker run --name zjx_mysql --net zjx_class -v /zjx_class/mysqlData:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=990812 -e MYSQL_DATABASE=zjxClass -d mysql:8.0.28
docker run --name zjx_minio --net zjx_class -p 9001:9001   -v /zjx_class/minioData:/data -d -e "MINIO_ROOT_USER=mataoxun" -e "MINIO_ROOT_PASSWORD=mtx990812" minio/minio:RELEASE.2022-02-07T08-17-33Z server /data --console-address ":9001"
docker run --name zjx_preview_file --net zjx_class -d 2359971480/zjx_preview_file:latest_alpine
docker run --name zjx_static --net zjx_class -d 2359971480/zjx_static:alpine_latest
docker run --name zjx_backend --net zjx_class -d 2359971480/zjx_backend:latest_alpine
docker run --name zjx_front --net zjx_class -d 2359971480/zjx_front:latest_alpine
docker run --name zjx_backend_front --net zjx_class -d 2359971480/zjx_backend_front:latest_alpine
docker run --name zjx_gateway --net zjx_class -d -p 80:80 2359971480/zjx_gateway:alpine_lastest
